// 全局事件控制器
export class EventManager {
    constructor() {
        this._eventArr = [];
    }
    on(eventName, call, func) {
        this._eventArr.push({ eventName, call, func });
    }
    off(eventName, func = null) {
        this._eventArr = this._eventArr.filter((e) => {
            if (func) {
                return !(eventName === e.eventName && func === e.func);
            }
            else {
                return !(eventName === e.eventName);
            }
        });
    }
    emit(eventName) {
        this._eventArr.forEach((e) => {
            if (e.eventName === eventName) {
                e.func.call(e.call);
            }
        });
    }
}
